package com.tgy.plus1.service;

import com.tgy.plus1.dao.UserDao;
import com.tgy.plus1.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/***
 * @ClassName: UserServiceImpl
 * @Description:
 * @Auther: 送你一块二向箔
 * @Date: 11:29 2022/3/25
 * @version : V1.0
 */
@Service
public class UserServiceImpl implements UserService{
    @Resource
    UserDao userDao;

    public void test(){
        List<User> users = this.userDao.selectList(null);
        users.forEach(System.out::println);
    }

    //@Transactional
    public  void testTransactional(){
        //如果不加事务就会删除
        System.out.println(this.userDao.deleteById(1));
        User user = new User();
        user.setName("tgy12345");
        this.userDao.insert(user);
        this.userDao.selectList(null).forEach(System.out::println);
    }

}
